<script type="text/javascript">
function valuesChanged()
{
	<?php if (count($shop->CurrentProduct->getAttributesVar()) > 2): ?>
	pageLoading();
	<?php endif; ?>
	jQuery('form#att_select_form').submit();
}

function checkValues(attId)
{
	if(attId > 0)
	{
		var curVariationValue = jQuery('#attribute_'+attId+'_value').val();
		var curSelectedValue = jQuery('#a_'+attId+'_v').val();
		if(curVariationValue != curSelectedValue)
		{
			pageLoading();
			jQuery('#attribute_'+attId+'_value').val(curSelectedValue);
			jQuery('form#att_select_form').submit();
		}
	}
}

function setAttUploadValue(attId, attType, trueValId, falseValId, currentValId, inputValue)
{
	if((attId > 0) && (attType > 0) && (trueValId > 0))
	{
		if(attType == 3) //Image upload
		{
			currentValId = jQuery('input#a_'+attId+'_v').val();
			var currentVarValId = jQuery('input#attribute_'+attId+'_value').val();
			
			if((currentValId != trueValId) || (currentVarValId != currentVarValId))
			{
				jQuery('#a_'+attId+'_v').val(trueValId);
				jQuery('input#attribute_'+attId+'_value').val(trueValId);
				pageLoading();
				jQuery('form#att_select_form').submit();
			}
		}
		
		if(attType == 4) //Text upload
		{
			var inputVal = '';
			if(inputValue != '')
			{ inputVal = inputValue; }
			
			currentValId = jQuery('input#a_'+attId+'_v').val();
			jQuery('#a_'+attId+'_v_input').val(inputValue);
			jQuery('#attribute_'+attId+'_value_cart').val(inputValue);
			
			if(isInputValid(attType, inputValue))
			{
				if(currentValId != trueValId)
				{
					jQuery('#a_'+attId+'_v').val(trueValId);
					jQuery('input#attribute_'+attId+'_value').val(trueValId);
					pageLoading();
					jQuery('form#att_select_form').submit();
				}
			}
			else
			{
				if(currentValId != falseValId)
				{
					jQuery('#attribute_'+attId+'_value_cart').val('');
					jQuery('#a_'+attId+'_v').val(falseValId);
					jQuery('input#attribute_'+attId+'_value').val(falseValId);
					pageLoading();
					jQuery('form#att_select_form').submit();
				}
			}
		}
	}
}

function isInputValid(attType, inputValue)
{
	//alert('isInputValid('+attType+', '+inputValue+')')
	var valid = false;
	if(attType == 4)
	{
		if(inputValue != '')
		{ valid = true; }
	}
	return valid;
}
</script>
<form id="att_select_form" name="att_select" action="" method="post" enctype="multipart/form-data" role="form" class="form">
<div class="attributes">
<?php 
foreach($shop->CurrentProduct->getAttributes() as $att)
{
	if($shop->getProductAttribute($att['id'])->getValues())
	{
		if($att['effect'] == 1)
		{
			if($att['type'] == 1)
			{ require($shop->getViewPath().'elements/attributes_type_1.php'); }
			if($att['type'] == 2)
			{ require($shop->getViewPath().'elements/attributes_type_2.php'); }
		}
	}
	if($att['val_types'] == 5)
	{
		if($att['type'] == 3)
		{ require($shop->getViewPath().'elements/attributes_type_3.php'); }
		if($att['type'] == 4)
		{ require($shop->getViewPath().'elements/attributes_type_4.php'); }
	}
}
?>
</div>
</form>